//
// Created by francklinson on 2021/11/24 AT 9:37.
// May Saint Diana bless you!
//

#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>

using namespace std;

class Solution {
public:
    string originalDigits(string s) {
        unordered_map<char, int> um;
        for (const char &x: s) {
            ++um[x];
        }
        vector<int> cnt(10);
        cnt[0] = um['z'];
        cnt[2] = um['w'];
        cnt[4] = um['u'];
        cnt[6] = um['x'];
        cnt[8] = um['g'];
        cnt[3] = um['h'] - cnt[8];
        cnt[5] = um['f'] - cnt[4];
        cnt[7] = um['s'] - cnt[6];
        cnt[1] = um['o'] - cnt[0] - cnt[2] - cnt[4];
        cnt[9] = um['i'] - cnt[5] - cnt[6] - cnt[8];
        string ans;
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < cnt[i]; ++j) {
                ans += char(i + '0');
            }
        }
        return ans;
    }
};

int main() {
    Solution solution;
    cout << solution.originalDigits("owoztneoer") << endl;
    cout << solution.originalDigits("fviefuro") << endl;
    return 0;
}

